<template>
  <div class="infinite-container">
    <div class="c">
      <empty v-if="isEmpty">暂无检验数据</empty>
      <ul class="jylist" v-else>
        <li v-for="(v, i) in reportList" :key="i" @click="toDetail(v)">
          <div class="des">{{v.inspectName}}</div>
          <mu-flexbox class="mt10">
            <mu-flexbox-item><small class="borderBtn">{{v.executeDepartmentName || v.departmentName}}</small></mu-flexbox-item>
            <mu-flexbox-item class="text-right t3 f12">{{v.inspectTime | format}}</mu-flexbox-item>
          </mu-flexbox>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
  import {commonAjax, RESTFUL_API} from '@/api/api'
  import empty from '@/components/empty'
  export default {
    data () {
      return {
        reportList: [],
        familyPerson: JSON.parse(sessionStorage.getItem('familyPerson')) || {},
        isEmpty: false
      }
    },
    components: {
      empty
    },
    mounted () {
      this.getReport()
    },
    methods: {
      toDetail (param) {
        this.$router.push({
          path: '/mainReportRecord/jyDetail',
          query: param
        })
      },
      getReport () {
        let param = {
          patientMedicalCardType: 1,
          source: 1,
          patientIdentityCardType: this.familyPerson.cardtype,
          patientIdentityCardNumber: this.familyPerson.idcard,
          patientCode: this.familyPerson.patientcode
        }
        if (sessionStorage.getItem('checkType') === '2') {
          param.source = 2
        }
        if (this.familyPerson.listHisBusCard.length > 1) {
          let tempCode = []
          this.familyPerson.listHisBusCard.forEach(v => {
            tempCode.push(v.patientBusCardId)
          })
          param.patientCode = tempCode.join(',')
        }
          commonAjax(RESTFUL_API.jyReport, param, true).then(res => {
          this.$store.commit('UPDATE_LOADING', false)
          if (res.data.code == 200) {
            if (res.data.data.length === 0) {
              this.isEmpty = true
              this.reportList = []
            } else {
              this.reportList = res.data.data
            }
          } else {
            this.$store.commit('UPDATE_TOAST', {message: res.data.message})
          }
        }).catch(res => {
              this.$store.commit('UPDATE_TOAST', {message: '服务忙'})
        })
      }
    }
  }
</script>

<style scoped lang="less">
  @import "../../common/css/flex.css";
  @import "../../common/css/app";
  .c{
    background-color: white;
  }

</style>
